Summit.Lib.JS.load('Data.Jax');
Summit.Lib.JS.load('UI.Widget.Fly_Option');

Summit.Util.Jax_Delete = function(settingsP)
{
	var settings = {
		'name':null,
		'feed':null,
		'action':'Update',
		'vars':{
			'row_status_ID':3
		},
		'row':false,
		'ondelete':function(){}
	}
	
	for(i in settingsP)
	{
		if(i=='vars')
		{
			for(i in settingsP.vars)
			settings.vars[i]=settingsP.vars[i];
		}
		else		
		settings[i] = settingsP[i];
	}
	
	var deleteOptionBox = new Summit.UI.Widget.Fly_Option({
		title:'Are You Sure You Want To Delete This ' + (settings.name ? settings.name : '') + '?',
		options: [
		{
			text:'Yes, Delete This ' + (settings.name ? settings.name : ''),
			onclick:function()
			{
				var Jax = new Summit.Data.Jax();
				Jax.feed=settings.feed;
				Jax.action=settings.action;
				
				for(i in settings.vars)
				Jax.Var(i,settings.vars[i]);
				
				Jax.handler=function(feed)
				{
					deleteOptionBox.close(function(){
						settings.ondelete();
						
						if(settings.row)
						{
							var row=settings.row;
							while(row.tagName != 'TR')
							row = row.parentNode
					
							var table = row.parentNode
							while(table.tagName != 'TABLE')
							table = table.parentNode
					
							
							row.fx.start({
							'opacity':0
							}).chain(function(){
								row.style.height=row.offsetHeight;
								row.empty();
								row.fx.start({'height': [40,0]});
							}).chain(function(){
								row.remove();
								table.jaxTable.recolorBody(table);
							});
						}
					})
				}
				Jax.Call();
			},
			hotKey:['y',13]
		},
		{
			text:'No, Do Not Delete ' + (settings.name ? settings.name : ''),
			onclick:function()
			{
				this.close();
			},
			hotKey:'n'
		}
		]
	});
	deleteOptionBox.open();
}